package dk.pun.aot.client.widget;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

import dk.pun.aot.client.view.MainView.Presenter;

public class AdministratorDialog extends DialogBox {

	private static AdministratorDialogUiBinder uiBinder = GWT.create(AdministratorDialogUiBinder.class);

	interface AdministratorDialogUiBinder extends UiBinder<Widget, AdministratorDialog> {}

	@UiField TextBox message;
	@UiField Button okButton;
	
	private Presenter presenter;
	
	public AdministratorDialog(Presenter presenter, String message) {
		setWidget(uiBinder.createAndBindUi(this));
		setText("Administrator");
		setAutoHideEnabled(true);
		setGlassEnabled(true);
		
		this.presenter = presenter;		
		this.message.setText(message);
	}

	@UiHandler("okButton")
	public void okButtonClicked(ClickEvent event) {
		this.presenter.onSystemMessageUpdated(this.message.getText());
		this.hide();
	}
	
}
